<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>修改页面</title>
	<link rel="stylesheet" href="/css/bootstrap.min.css">
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
	<script src="/js/jquery.validation/1.14.0/messages_zh.min.js"></script>
</head>
<body>
<form id="edit">
	<div style="margin:0 auto;width:30%;">
		<table class="table table-bordered">
			<tr>
				<td>编号</td>
				<td><input name="lid" value="${edititem.lid}" readonly="readonly"/></td>
			</tr>
			<tr>
				<td>姓名</td>
				<td><input name="lname" id="lname" value="${edititem.lname}"/></td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input name="lpwd" id="lpwd" value="${edititem.lpwd}"/></td>
			</tr>
			<tr>
				<td>地址</td>
				<td><input name="laddress" id="laddress" value="${edititem.laddress}"/></td>
			</tr>
			<tr>
				<td colspan="2"><button type="button" id="saveBtn" class="btn btn-success">提交</button>
		  		<button type="button" id="cancelBtn" class="btn btn-default">取消</button>
		  		</td>
		  	</tr>
		</table>
	</div>
</form>
</body>
	<script>
		var editUser = function(){
				if(!check().form()){ 
					return;  
				}
			$.ajax({
				   type: "GET",
				   dataType: "json",
				   url: "/showall/edit",
				   data: {
						"lid": ${edititem.lid},
						"lname": $("#lname").val(),
						"lpwd":$("#lpwd").val(),
						"laddress":$("#laddress").val()
				   },
				   success: function(msg){
						$('#cancelBtn').click();			
				   }
			});
		}
		$('#saveBtn').on('click', function(){
			editUser();
		});
			
		$('#cancelBtn').on('click', function(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.getUserPageList();
			parent.layer.close(index);
		});
		//校验字段是否正确 
        function check(){ 
            /*返回一个validate对象，这个对象有一个form方法，返回的是是否通过验证*/ 
            return $("#edit").validate({ 
                        rules:{ 
                            lname:{ 
                                required:true
                            },
                            lpwd:{ 
                                required:true                                   
                            },
                            laddress:{ 
                                required:true                                   
                            }
                        }, 
                        messages:{ 
                            lname:{ 
                                required:"请输入用户名"
                            },
                            lpwd:{ 
                                required:"请输入密码"                                   
                            },
                            laddress:{ 
                                required:"请输入地址"                                   
                            }
                        }     
                    }); 
        }
	</script>
</html>